import React from "react";
import {
  FlatList,
  StyleSheet,
  Dimensions,
  View, Text,
} from "react-native";

//获取设备的宽高
const width=Dimensions.get('window').width;
const height = Dimensions.get("window").height;

const arr=[
  {
    id:1,
    data:'苹果'
  },
  {
  id:2,
    data:'香蕉',
  },
  {
    id:3,
    data:'梨子'
  },
  {
    id:4,
    data:'火龙果'
  }
]


class Demo1 extends React.Component{
  constructor(props) {
    super(props);
    this.state={
      arr
    }
  }

  renderDate({item}){
    return(
      <Text>{item.data}</Text>
    )
  }

  render() {
    return (
     <View>
       {/*numColumns指定多少行数据*/}
       <FlatList numColumns={1} data={this.state.arr} renderItem={this.renderDate}/>
     </View>
    );
  }
}
const styles=StyleSheet.create({

})
export default Demo1
